<%@page import="model.Billet"%>
<%@page import="model.Achat"%>
<%@page import="model.Utilisateur"%>
<%@page import="dao.DaoBillet"%>
<%@page import="dao.DaoAchat"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>

<% if((Utilisateur)session.getAttribute("user_connected") != null ){ %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title>Achat et vente de billets</title>
	<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
	<!--[if lte IE 6]><link rel="stylesheet" href="css/ie6.css" type="text/css" media="all" /><![endif]-->
	
	<meta name="keywwords" content="Shop Around - Great free html template for on-line shop. Use it as a start point for your on line business. The template can be easily implemented in many open source E-commerce platforms" />
	<meta name="description" content="Shop Around - Great free html template for on-line shop. Use it as a start point for your on line business. The template can be easily implemented in many open source E-commerce platforms" />
	
	<!-- JS -->
	<script src="js/jquery-1.4.1.min.js" type="text/javascript"></script>	
	<script src="js/jquery.jcarousel.pack.js" type="text/javascript"></script>	
	<script src="js/jquery-func.js" type="text/javascript"></script>	
	<!-- End JS -->
	
</head>
<body>
	
<!-- Shell -->	
<div class="shell">
	
	<!-- Header -->	
	<%@ include file="header.jsp" %>
	
	<!-- Main -->
	<div id="main">		
		<!-- Principal -->
		<div id="principal">
			<br />
			<h1>Bienvenue!</h1><br/>
		
			<div class="billet-info">
	    		<div class="billet-desc" style="padding-left: 40px;">
	    		
	    			<%
		    			Utilisateur user_accueil = (Utilisateur)session.getAttribute("user_connected");
	    				int userid = user_accueil.getIdUtilisateur();
	    			%>
	    		
	    			<h2>Mes Informations!</h2><hr/>
	    			
	    			<table style="" align="center" cellspacing="7">
	    				<tr>
	    					<td><h3><%=user_accueil.getNomUtilisateur()%>  <%=user_accueil.getPrenomUtilisateur()%></h3></td>	    					
	    				</tr>
	    				<tr>
	    					<td><p>Login : <%=user_accueil.getLogin()%></p></td>
	    				</tr>
	    			</table>
	    			
	    			<br/>
	    		
	    			<% 
	    				DaoBillet daobillet = new DaoBillet();	    				
	    				ArrayList<Billet> listeBillet = (ArrayList<Billet>)daobillet.getBilletByUser(userid);
						if(listeBillet.size() == 0){
	    			%>
	    			
	    			<h2>Mes billets</h2><hr/>
	    			<br/>
	    			<p>Aucune Vente pour le moment!</p>
	    			
	    			<%}else{ %>
	    			
	    			<h2>Mes billets</h2><hr/>
	    			
	    			<table style="" align="center" cellspacing="7">						
						<tr>
							<td><h2></h2></td>
							<td><h2>Ville Depart</h2></td>
							<td><h2>Ville arrivee</h2></td>
							<td><h2>Date Depart</h2></td>
							<td><h2>Heure Depart</h2></td>
							<td><h2>Prix</h2></td>
						</tr>
						<% for(Billet billet : listeBillet){ %>
						<tr>								
							<td>
								<a href="details_billet.jsp?idbillet=<%= billet.getIdBillet() %>
										 &villedep=<%= billet.getVilleDepart() %>
										 &villearr=<%= billet.getVilleArrivee() %>
										 &datedep=<%= billet.getDateDepart() %>
										 &heuredep=<%= billet.getHeureDepart() %>
										 &prixvente=<%= billet.getPrixVente() %>
										 &prixachat=<%= billet.getPrixInitial() %>
										 &validite=<%= billet.getValiditeBillet() %>
										 &dateenligne=<%= billet.getDateMiseEnLigne() %>"><%= billet.getImageBillet() %></a>
							 </td>
							<td><h3><%= billet.getIdBillet() %></h3></td>
							<td><h3><%= billet.getVilleArrivee() %></h3></td>
							<td><h3><%= billet.getDateDepart() %></h3></td>
							<td><h3><%= billet.getHeureDepart() %></h3></td>
							<td><h3><%= billet.getPrixVente() %></h3></td>							
						</tr>
						<%}%>
					</table>
					
					<%} %>
					
					<br/>			
					
	    			<% 
	    				DaoAchat daoachat = new DaoAchat();
	    				ArrayList<Achat> listeAchat = (ArrayList<Achat>)daoachat.getAchatByUser(userid);
	    				if(listeAchat.size() == 0){
	    			%>
	    			
	    			
	    			<h2>Mes Commandes</h2><hr/>
	    			<br/>
	    			<p>Aucune commande pour le moment !</p>
	    			
	    			<%}else{ %>
	    			
	    			<h2>Mes Commandes</h2><hr/>
	    			
	    			<table style="" align="center" cellspacing="20">						
						<tr>
							<td><h2></h2></td>
							<td><h2>Date Achat</h2></td>
							<td><h2>Montant</h2></td>
							<td><h2>Etat Achat</h2></td>
							<td><h2>Date Livraison</h2></td>
						</tr>
						<% for(Achat achat : listeAchat){ %>
						<tr>								
							<td><h3><%= achat.getDateAchat() %></h3></td>
							<td><h3><%= achat.getMontant() %></h3></td>
							<td><h3><%= achat.getEtatAchat() %></h3></td>
							<td><h3><%= achat.getDateLivraison() %></h3></td>
						</tr>
						<%}%>
					</table>
					<%} %>
					
				</div>
			</div>	
			
		</div>
		<!-- End Content -->
		
		<!-- Sidebar -->
		<div id="sidebar">
			
			<!-- Search -->
			<%@ include file="search.jsp" %>
			
			<!-- Menus -->
			<%@ include file="menus_user.jsp" %>
			
		</div>
		<!-- End Sidebar -->
		
		<div class="cl">&nbsp;</div>
	</div>
	<!-- End Main -->
	
	<!-- Side Full -->
	<%@ include file="foot_slide.jsp" %>
	
	<!-- Footer -->
	<%@ include file="footer.jsp" %>

</div>	
<!-- End Shell -->
	
</body>
</html>
<%} else { response.sendRedirect("index.jsp"); } %>